<?php

namespace App\Exceptions;

use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Support\Facades\Http;
use Throwable;

class Handler extends ExceptionHandler
{
    /**
     * The list of the inputs that are never flashed to the session on validation exceptions.
     *
     * @var array<int, string>
     */
    protected $dontFlash = [
        'current_password',
        'password',
        'password_confirmation',
    ];

    /**
     * Register the exception handling callbacks for the application.
     */
    public function register(): void
    {
        $this->reportable(function (Throwable $e) {
            Http::withHeaders(['Content-Type' => 'application/json'])
                ->withoutVerifying()
                ->post('https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=87690f40-1c07-4885-952f-fc75bdc4c9ab', [
                    'msgtype' => 'text',
                    'text' => [
                        'content' => '系统:'.env('APP_NAME')."\n消息:".$e->getMessage()."\n文件:".$e->getFile()."\n行号:".$e->getLine()
                    ]
                ]);
        });
    }
}
